package com.heima.behavior.controller.v1;



import com.heima.behavior.service.ArticleLikesService;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.LikesDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api/v1")
public class ArticleLikesController {
    @Autowired
    private ArticleLikesService articleLikesService;
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto dto) {
        return articleLikesService.getLikes(dto);
    }

    @PostMapping("/is_likes")
    public Boolean isLikes(@RequestBody LikesBehaviorDto dto) {
        return articleLikesService.isLike(dto);
    }


    @Scheduled(cron = "* 0/30 * * * ?")
    public void getLikes() {
        articleLikesService.getArticleLikes();
    }
}
